import React from 'react';
import {increamentAction} from './store/action/actionCounter'
import {connect} from 'react-redux';

function App(props){
  // const {count,actionIncrement} = props
  const {count,increamentAction} = props
  return (
    <div>
      <p>count:{count}</p>
      <button onClick={increamentAction}>Sync+</button>
    </div>
  )
}

//01 mapState 版本
// const mapState = (state)=>{
//   return {count:state.reducerCounter.count}
// }
//02 mapState 版本
// const mapState = (state)=>({count:state.reducerCounter.count})

// 03 mapState 版本
const mapState = state=>({count:state.reducerCounter.count})

//01 mapDispatch 版本
// const mapDispatch = (dispatch)=>{
//   return {
//     actionIncrement:()=>{
//       dispatch(increamentAction())
//     }
//   }
// }


//02 mapDispatch 版本
// const mapDispatch = (dispatch)=>({
//     actionIncrement:()=>{dispatch(increamentAction())}
//   })

//03 mapDispatch 版本
// const mapDispatch = dispatch=>({
//     actionIncrement:()=>dispatch(increamentAction())
// })

//04 mapDispatch 版本 : 默认dispatch
// const mapDispatch = {
//     actionIncrement:()=>(increamentAction()) //increamentAction()执行=>()=>({type:CONSTANT.INCREMENT})
// }

//05 mapDispatch 版本
// const mapDispatch = {
//     actionIncrement:increamentAction
// }

//06 mapDispatch 版本
// const mapDispatch = {
//   increamentAction:increamentAction
// }
// const mapDispatch = {
//   increamentAction
// }


//07  mapDispatch 版本
export default connect(mapState,{increamentAction})(App)


// export default connect(mapState,mapDispatch)(App) 